package org.albertsanso.yoigo.shopchat;

import java.util.List;

import org.albertsanso.yoigo.shopchat.model.Tienda;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class TiendasSpinnerAdapter extends ArrayAdapter<Tienda> {

	private Context context;
	private List<Tienda> values;
	
	public TiendasSpinnerAdapter(Context context, int resource, List<Tienda> objects) {
		super(context, resource, objects);
		this.context = context;
		this.values = objects;
	}
	
	public int getCount() {
		return values.size();
	}
	
	public Tienda getItem(int position) {
		return values.get(position);
	}
	
	public long getItemId(int position) {
		return position;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		Tienda tienda = values.get(position);
		
		TextView label = new TextView(context);
		label.setTextColor(Color.BLACK);
		label.setText(tienda.getCodigo()+"-"+tienda.getCiudad()+""+tienda.getDireccion());
		
		return label;
	}

	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		
		Tienda tienda = values.get(position);
		
		TextView label = new TextView(context);
		label.setTextColor(Color.BLACK);
		label.setText(tienda.getCodigo()+"-"+tienda.getCiudad()+""+tienda.getDireccion());
		
		return label;
	}

	
}
